<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
  function foo(f){
      console.log(f);
      if (typeof f === 'function'){
        f();
      }

  }
  function A(){
      console.log('I am A function');
  }
  console.log(typeof A);

  foo(A);//函数 A作为参数



  function boo(f){
      var template = '<h2>$tpl$</h2>';
      f(template);
  }

  function myF(s){
      console.log(s)
  }
  function myF2(s){
      alert(s)
  }
  boo(myF2);    //myF 或 myF2 作为参数
</script>
</body>
</html>